package cn.iocoder.ny.module.mall.domain;

import cn.iocoder.ny.module.mall.domain.SmsReport;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Data
public class SmsReportRequest {
    private List<String> data;  // 接收的是字符串数组

    // 无参构造函数
    public SmsReportRequest() {}

    // 手动解析字符串为 SmsReport 对象
    public List<SmsReport> getSmsReports() throws IOException {
        List<SmsReport> smsReports = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();

        // 将每个 JSON 字符串解析为 SmsReport 对象
        for (String reportJson : data) {
            SmsReport smsReport = objectMapper.readValue(reportJson, SmsReport.class);
            smsReports.add(smsReport);
        }

        return smsReports;
    }
}
